<?php
// +----------------------------------------------------------------------
// | User: zq
// +----------------------------------------------------------------------
// | 2021-09-15 22:26:24
// +----------------------------------------------------------------------
use Workerman\Worker;
require_once __DIR__ . '/workerman/Autoloader.php';

// 创建一个websocket协议的Worker监听7272接口
$worker = new Worker('websocket://0.0.0.0:7272');

// 只启动一个进程,这样方便客户端之间传输数据
$worker0->count = 1;

$uid = 0;

// 当客户端连上来时
$worker->onConnect = function($connection){
    global $ws_worker, $uid;
    // 为这个连接分配一个uid
    $connection->uid = ++$uid;
}